A
}} |element-type = Normal |spec-version = 1.0 |status = Active |context = Where phrasing content is expected |categories = Flow content, phrasing content, palpabale content |content-model = Transparent |description = This element represents a hyperlink or a placeholder for a link. |dom-interface = HTMLAnchorElement }} The HTML element is used to create links, called hyperlinks or anchors, to other resources on the internet. Examples of such resources are other webpages, e-mail addresses, downloadable files, etc. This is done using the href attribute, which indicates the link's destination in the form of it's URI. Example of a hyperlink: hyperlink In HTML 5, this is the only possible use of the element. In HTML 4 and below, it is one of two possible uses. The other function is to mark a position (know as fragment) in a document that another hyperlink can point to, using a so-called fragment identifier. This way, the element becomes the destination of a hyperlink. This is done using the name attribute. One element can be both a source and destination, by having both a href and a name attribute. The destination functionality has been replaced by using the generic attribute id on any HTML element. Example of such use: link to target target By default, links will appear as follows in all browsers: * An unvisited link is underlined and colored blue (ex. ) * A visited link is underlined and colored purple (ex. ) * An active link is underlined and colored red (ex. ) Attributes HTML example: HTML & CSS Wiki This element can also be used to link to an email address which the user can click on to send messages. Here is an example: Click here to message Wikia staff. To link to an email on Wikia wikis, it is the same as linking to an external source: mailto:community@wikia.com That makes this: mailto:community@wikia.com which will allow you to send a message to Wikia staff when you click on it. Rendering Most graphical web browsers render links in blue with an underline, and the mouse pointer changes to a hand cursor while hovering over it. Visited links are colored purple, and active ones are red. Focused anchors show a dotted outline in the same color as the link text. Most browsers have settings that allow the user to modify the default colors and underlining, and possibly even block these from being modified by the website. Link colors can also be modified using the (deprecated) attributes (for general links), (for active links) and (for visited links) of the element. Named links (destinations) are not rendered differently from normal text. Typical CSS representation a:link { cursor: pointer; text-decoration: underline; color: #0000EE; } a:active { color: #EE0000; } a:visited { color: #551A8B; } a:focus { outline: 1px dotted; } Notable exceptions Mobile Safari: * Focus and hover are not supported. * Active links are not colored, but have a semi-transparent black background. Mobile Chrome: * Hover is not supported. * Focused elements get an orange outline with rounded corners. * Active links are not colored, but have a semi-transparent orange background. Opera Mini: * Hyperlinks are not underlined. * Visited links are dark blue (#000070). * Focused links have a blue outline and a semi-transparent blue background. * Active links show a less-transparent blue background. Gmail mobile web interface: * All hyperlinks are converted to plain text. * Instead, plain text URL's are converted to hyperlinks. Example HTML source: Testing hyperlink and URL http://anotherexample.com/ Gmail's mobile web interface will convert this to: Testing hyperlink and URL http://anotherexample.com/ Conclusions * Hover, focus and active states are not available on all devices. Do not depend on them to supply vital information. For example, not all users can view a link destination by hovering over the link. * When sending emails, always include full URLs of hyperlinks in the text. Coding rules The element belongs to the Flow content category. Category:Flow content Category:HTML Elements Category:Inline elements